#ifndef __MathMisc__h__included__
#define __MathMisc__h__included__

namespace neiderra {
	namespace math {

		const float pi = 3.141592;

		// returns the 1st power of 2 that is > n
		inline int next_p2(int n)
		{
			int rval=1;
            while(rval < n) rval<<=1;
			return rval;
		}

		template<class T> inline T findMaxElement(T* array, int num)
		{
			T tmpEl = 0, indxEl=0;
			for(int index=0;index<num;index++)
			{
                indxEl = array[index];
				if(tmpEl < indxEl)
					tmpEl = indxEl;
			}
			return tmpEl;
		}

		//template<class T> inline T max(T a, T b)
		//{
		//	if(a >= b)
		//		return a;
		//	else 
		//		return b;
		//}

		//inline template<class T> void factorArrayWith(T* array, int num, T factor)
		//{
		//	for(int i=0; i<num; i++)
		//		array[i] *= factor;
		//}
	}
}

#endif
